package com.my.internetplus.result;


//js返回的数据需要包装 加一些请求成功/失败之类的数据
public class BaseResult<T> {
    //成功/失败的状态码
    private int code;
    //描述信息
    private String msg;
    private T data;

    public static <T> BaseResult<T> success(T data) {
        BaseResult<T> result = new BaseResult<>();
        result.code = 0;
        result.msg = "success";
        result.data = data;
        return result;
    }

    public static <T> BaseResult<T> fall(int code, String msg) {
        BaseResult<T> result = new BaseResult<>();
        result.code = code;
        result.msg = msg;
        return result;

    }

    //    把对象转换成json的时候 spring需要使用这些方法
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
